package com.dachuang.canjiren.controller;


import com.dachuang.canjiren.entity.Banner;
import com.dachuang.canjiren.mapper.BannerMapper;
import com.dachuang.canjiren.service.IBannerService;
import com.dachuang.canjiren.service.impl.BannerServiceImpl;
import com.dachuang.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/canjiren/banner")
public class BannerController {

    @Autowired
    private IBannerService bannerService;

    /**
     * 插入一个轮播图
     * @param img
     * @param url
     * @param title
     * @return
     */
    @GetMapping(value = "save")
    R saveBanner(@RequestParam(value = "img",required = false) String img,
                 @RequestParam(value = "url",required = false) String url,
                 @RequestParam(value = "title",required = false) String title){
        return bannerService.insertBanner(img, url, title);
    }

    /**
     * 获取轮播图列表
     * @return
     */
    @GetMapping(value = "list")
    R list(){
        return bannerService.selectList();
    }
}

